package com.xilin.kotlincoroutine.activity

import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.xilin.kotlincoroutine.R
import com.xilin.kotlincoroutine.databinding.ActivityMainBinding
import com.xilin.kotlincoroutine.viewmodel.MainViewModel

class MainActivity : AppCompatActivity() {
    private val mainViewModel: MainViewModel by viewModels()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val binding = DataBindingUtil.setContentView<ActivityMainBinding>(
            this,
            R.layout.activity_main
        )
        binding.viewmodel = mainViewModel
        binding.lifecycleOwner = this
        binding.button.setOnClickListener {
            mainViewModel.getUser("小米")
        }
    }
}